﻿using RBAC.Repository.RabbitImpl;
using RBAC.Repository.RabbitInterfae;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Traceability.Domain;
using Traceability.Service.Interfae;

namespace Traceability.Service.Impl
{
    public class AuxiliaryService : IAuxiliaryService
    {
        private readonly IAuxiliaryRepository _auxiliaryRepository;
        public AuxiliaryService(IAuxiliaryRepository auxiliaryRepository)
        {
            _auxiliaryRepository = auxiliaryRepository;
        }
        /// <summary>
        /// 添加辅料信息
        /// </summary>
        /// <param name="auxiliary"></param>
        /// <returns></returns>
        public async Task<int> AddAuxiliary(Auxiliary auxiliary)
        {
           return await _auxiliaryRepository.AddAsync(auxiliary);
        }
        /// <summary>
        /// 反填辅料信息
        /// </summary>
        /// <param name="AuxiliaryId"></param>
        /// <returns></returns>
        public async Task<List<Auxiliary>> GetAuxiliaryBy(string bath)
        {
            return await _auxiliaryRepository.GetAsync(d => d.Batch == bath);
        }
        /// <summary>
        /// 显示辅料信息
        /// </summary>
        /// <param name="bacth"></param>
        /// <returns></returns>
        public async Task<List<Auxiliary>> GetAuxiliaryList(int tid)
        {
            return await _auxiliaryRepository.GetAsync(d => d.TraceabilityId==tid);
        }
        /// <summary>
        /// 修改辅料信息
        /// </summary>
        /// <param name="auxiliary"></param>
        /// <returns></returns>
        public async Task<int> UpdateAuxiliary(Auxiliary auxiliary)
        {
           return await _auxiliaryRepository.UpdateAsync(auxiliary);
        }
    }
}
